package com.ghck.server.utils;

import org.joda.time.DateTime;

import com.ghck.server.model.BodypartDict;
import com.ghck.server.model.DepartmentDict;
import com.ghck.server.model.DictDiseaseKey;
import com.ghck.server.model.Disease;
import com.ghck.server.model.DiseaseKeyword;
import com.ghck.server.model.FriendPatientEventDay;
import com.ghck.server.model.HospitalDict;
import com.ghck.server.model.NurseStationDict;
import com.ghck.server.model.PatientEventDay;
import com.ghck.server.model.RegionDict;
import com.ghck.server.model.TestCategoryDict;
import com.ghck.server.model.response.TestCategoryDictRes;

public class RedisKeyUtil {

	/**
	 * 用户最近一条健康数据
	 *  eg: userId[100].patientEvent
	 */
	public static String userLastPatientEventMapKey(Integer userId){
		StringBuilder sb = new StringBuilder();
		sb.append("userId[").append(userId).append("].patientEvent");
		return sb.toString();
	}

	/**
	 *  用户-亲友最近一条健康数据
	 *  eg: friendId[100].patientEvent
	 */
	public static String friendLastPatientEventMapKey(Integer friendId){
		StringBuilder sb = new StringBuilder();
		sb.append("friendId[").append(friendId).append("].patientEvent");
		return sb.toString();
	}
	
	/**
	 * 用户最近7条健康血压数据
	 * 
	 * zset
	 */
	public static String userBloodPressureZSetKey(Integer userId){
		StringBuilder sb = new StringBuilder();
		sb.append("userId[").append(userId).append("].bloodPressureZSetKey");
		return sb.toString();
	}

	public static String bloodPressureZSetForHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(PatientEventDay.class).append(".bloodPressureId");
		return sb.toString();
	}

	/**
	 * 朋友最近7条健康血压数据
	 * 
	 * zset
	 */
	public static String friendBloodPressureZSetKey(Integer userId){
		StringBuilder sb = new StringBuilder();
		sb.append("friendId[").append(userId).append("].bloodPressureZSetKey");
		return sb.toString();
	}

	public static String friendBloodPressureZSetForHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(FriendPatientEventDay.class).append(".bloodPressureId");
		return sb.toString();
	}
	

	/**
	 * 用户最新一条问卷调查记录
	 * 返回TestAnswer
	 */
	public static String userLastQuestionnaireValueKey(Integer userId){
		StringBuilder sb = new StringBuilder();
		sb.append("userId[").append(userId).append("].questionnaire");
		return sb.toString();
	}
	
	/**
	 * 用户积分总数
	 * @return 
	 */
	public static String userCreditTotalValueKey(Integer userId){
		StringBuilder sb = new StringBuilder();
		sb.append("userId[").append(userId).append("].creditTotal");
		return sb.toString();
	}
	
	/**
	 * 用户签到状态
	 * 第二天过期
	 */
	public static String userSignInValueKey(Integer userId){
		String taday = DateTime.now().toString("yyyy-MM-dd");
		StringBuilder sb = new StringBuilder();
		sb.append("userId[").append(userId).append("]date[").append(taday).append("].creditTotal");
		return sb.toString();
	
	}
	
	
	/**
	 * HashMap
	 * id-domain
	 */
	public static String domainIdKey(Object id){
		StringBuilder sb = new StringBuilder();
		sb.append("id[").append(id).append("]");
		return sb.toString();
	}
	

	
//=============================== 区域 ==========================================	
	public static String regionHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(RegionDict.class.getName()).append(".hashMapKey");
		return sb.toString();
	}
	
	public static String parentIdMapRegionChildren(){
		StringBuilder sb = new StringBuilder();
		sb.append(RegionDict.class.getName()).append(".children");
		return sb.toString();
	}
	
//=============================== 科室 ==========================================	
	/**
	 * DepartmentHashKey
	 */
	public static String departmentHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(DepartmentDict.class.getName()).append(".hashMapKey");
		return sb.toString();
	}
	
	/**
	 * List
	 * department parentId-children
	 */
	public static String parentIdMapDepartmentChildren(){
		StringBuilder sb = new StringBuilder();
		sb.append(DepartmentDict.class.getName()).append(".children");
		return sb.toString();
	}

//=============================== 医院 ==========================================
	/**
	 * HospitalHashKey
	 */
	public static String hospitalHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(HospitalDict.class.getName()).append(".hashMapKey");
		return sb.toString();
	}
	
//	/**
//	 * List
//	 * hospitalId-departmentIds
//	 */
//	public static String hospitalIdMapDepartments(Integer hospitalId){
//		StringBuilder sb = new StringBuilder();
//		sb.append(HospitalDict.class.getName()).append(".id[").append(hospitalId).append("].departments");
//		return sb.toString();
//	}
	
	public static String regionIdMapHosptialIdList(){
		StringBuilder sb = new StringBuilder();
		sb.append(RegionDict.class.getName()).append(".hospitals");
		return sb.toString();
	}
	
	
//===================================身体部位======================================
	/**
	 * 身体部位
	 */
	public static String bodypartHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(BodypartDict.class.getName()).append(".hashMapKey");
		return sb.toString();
	}
	
	public static String bodyIdMapDiseaseIdNameList(){
		StringBuilder sb = new StringBuilder();
		sb.append(BodypartDict.class.getName()).append(".diseases");
		return sb.toString();
	}
	
//====================================疾病====================================	
	/**
	 */
	public static String diseaseHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(Disease.class.getName()).append(".hashMapKey");
		return sb.toString();
	}

	public static String diseaseIdMapBodyPartIdNameList(){
		StringBuilder sb = new StringBuilder();
		sb.append(Disease.class.getName()).append(".bodyparts");
		return sb.toString();
	}

//====================================疾病字段对应KEY====================================
	public static String dictDiseaseListKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(DictDiseaseKey.class.getName()).append(".listKey");
		return sb.toString();
	}
	
//============================= 试卷hashKey ============================
	public static String paperHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(TestCategoryDictRes.class.getName()).append(".hashMapKey");
		return sb.toString();
	}
	
	public static String paperSampleHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(TestCategoryDict.class.getName()).append(".hashMapKey");
		return sb.toString();
	}
	
	public static String parentIdMapPaperSampleChildren(){
		StringBuilder sb = new StringBuilder();
		sb.append(TestCategoryDict.class.getName()).append(".children");
		return sb.toString();
	}
	
	

//============================  疾病热词  =============================
	
	public static String keywordHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(DiseaseKeyword.class.getName()).append(".hashMapKey");
		return sb.toString();
	}
	
//============================  护士站  =============================
	
	public static String nurseStationDictHashKey(){
		StringBuilder sb = new StringBuilder();
		sb.append(NurseStationDict.class.getName()).append(".hashMapKey");
		return sb.toString();
	}

}
